#include <iostream>
#include <vector>
using namespace std;

class App {
	int cnt, vertex;
	vector<int> head, next, to;
	vector<int> size, maxsub, ans;

	void addedge(int u, int v)
	{
		next[cnt] = head[u];
		to[cnt] = v;
		head[u] = cnt++;
	}

	void dfs(int u, int p)
	{
		bool iscenter = true;
		size[u] = 1;
		maxsub[u] = 0;
		for (int e = head[u], v = 0; e; e = next[e]) {
			v = to[e];
			if (v != p) {
				dfs(v, u);
				size[u] += size[v];
				maxsub[u] = max(maxsub[u], size[v]);
			}
		}
		maxsub[u] = max(maxsub[u], vertex - size[u]);
	}

    public:
	App(int n) : cnt(1), vertex(n), head(n + 1, 0), next(n << 1, 0), to(n << 1, 0), size(n + 1, 0), maxsub(n + 1, 0), ans(2, 0)
	{
	}

	void run(int n)
	{
		for (int i = 0, u, v; i < n - 1; i++) {
			cin >> u >> v;
			addedge(u, v);
			addedge(v, u);
		}
		dfs(1, 0);
		int cnt = 0;
		for (int i = 1; i <= n; i++) {
			if (maxsub[i] <= n >> 1) {
				ans[cnt++] = i;
			}
		}
		if (cnt == 1) {
			cout << ans[0] << '\n';
		} else {
			cout << ans[0] << ' ' << ans[1] << '\n';
		}
	}
};

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n = 0;
	cin >> n;
	App app(n);
	app.run(n);
	return 0;
}